Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: UIKit Navigation instrimentation #22

Merged
merged 28 commits into from
Nov 22, 2024

Conversation

arriIsHere
Copy link
Contributor

Which problem is this PR solving?

Adds auto-instrimentation for UIKit navigation.

  • Closes #

Short description of the changes

Swizzles the UIViewController viewDidAppear and viewDidDisappear to observe

How to verify that this has the expected result

Some smoke tests were added that verify the collection of data (WIP needs to be more granular)

@arriIsHere arriIsHere force-pushed the arriIsHere.ui-navigation-controller-instrumentation branch 2 times, most recently from e6fdbcc to 984b43f Compare November 18, 2024 15:35
Copy link
Collaborator

@beekhc beekhc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted to give some early feedback, even though I know we're discussing some of the details later.

I think we should also document the new spans and attributes in the Readme.

@@ -65,6 +65,15 @@ struct ContentView: View {
NetworkView()
.padding()
.tabItem { Label("Network", systemImage: "network") }

UIKView()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name UIKView feels very wrong to me. Objective C didn't have namespaces, so the convention was to use two letter (and later, three letter) prefixes to avoid naming collisions. "UI" was the prefix for UIKit. My brain can't help but read UIKView as a View in the UIK namespace. I'd recommend just making it UIKitView.

let app = XCUIApplication()
app.launch()
app.buttons["UIKit"].tap()
XCTAssert(app.staticTexts["Sample UIKit App"].waitForExistence(timeout: uiUpdateTimeout))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're swizzling UIViewController, this instrumentation should work for both UINavigationContoller and UITabBarController, among others. Should we add tests for both a navigation controller and a tab view, to make sure they're both reasonable? I'm not sure how annoying that would be to build in Storyboard.

import OpenTelemetryApi
import UIKit

private let honeycombInstrumentationView = "@honeycombio/instrumented-view"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #20 is probably gonna go in before this one, and has "@honeycombio/instrumentation-view". Let's find a place where we can put it as a constant and reuse it. Maybe all of our tracer names should be in one file? 🤔

@arriIsHere arriIsHere force-pushed the arriIsHere.ui-navigation-controller-instrumentation branch from 5d68eb6 to ef672fe Compare November 20, 2024 19:25
@arriIsHere arriIsHere force-pushed the arriIsHere.ui-navigation-controller-instrumentation branch from ef672fe to a11a82e Compare November 20, 2024 19:26
@arriIsHere arriIsHere requested a review from beekhc November 21, 2024 13:29
@arriIsHere arriIsHere marked this pull request as ready for review November 21, 2024 13:41
@arriIsHere arriIsHere requested a review from a team as a code owner November 21, 2024 13:41
Copy link
Collaborator

@beekhc beekhc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! 🚀

// SmokeTest
//
// Created by Arri Blais on 11/13/24.
//
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should delete these headers. You can change the template in Xcode settings somewhere.

README.md Outdated
@@ -76,6 +76,16 @@ To manually send a span:
The following auto-instrumentation libraries are automatically included:
* [MetricKit](https://developer.apple.com/documentation/metrickit) data is automatically collected.

### UIKit instrumentation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It looks like we capitalized "Instrumentation" everywhere else, so let's be consistent.

@arriIsHere arriIsHere force-pushed the arriIsHere.ui-navigation-controller-instrumentation branch from 16bd1cb to 8586f74 Compare November 22, 2024 13:38
@arriIsHere arriIsHere merged commit 90b5db5 into main Nov 22, 2024
6 checks passed
@arriIsHere arriIsHere deleted the arriIsHere.ui-navigation-controller-instrumentation branch November 22, 2024 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants